const fs = require('fs');

//编码jpg

//编码
function base64_encode(file) {
    let bitmap = fs.readFileSync(file);
    return new Buffer.from(bitmap).toString('base64');
}

//解码
function base64_decode(base64str, file) {
    var bitmap = new Buffer.from(base64str, 'base64');
    fs.writeFileSync(file, bitmap);
}